package com.gtmonitor;

import android.content.Context;
import android.util.Log;

public class JNIInterface {
    
    private static JNIInterface singleton = null;
    
    // Design Pattern "Singleton"
    public static JNIInterface getInstance() {
        if(singleton == null) {
            System.loadLibrary("gtmonitor");
            singleton = new JNIInterface();
        }
        return singleton;
    }
    
    // System 
    public native void  hold();
    public native void  resume();
    public native void  setFreeze(int freeze);
    public native long  getInterval(); 
    public native int   getHZ();
    public native void  exit();
    public native void  setCPULogging(boolean on);
    public native void  setMemLogging(boolean on);
    public native void  setDskLogging(boolean on);
    public native void  setNetLogging(boolean on);
    
    // Storage
    public native int   getStorageTotal();
    public native float getStorageTotalUtil();
    public native float getStorageUtil(int index);
    public native String getStorageName(int index);
    public native long  getSdptot(int index);
    public native long  getSdctot(int index);
    
    // Process
    public native int   getSelfLoad();
    public native int   getProcessTotal(); 
    public native int   getProcessThreads(int index);
    public native int   getProcessPID(int index);
    public native int   getProcessUID(int index);
    public native long  getProcessStime(int index);
    public native long  getProcessUtime(int index);
    public native int   getProcessLoad(int index);
    public native int   getProcessRSS(int index);
    public native String getProcessName(int index);
    public native String getProcessNameByUid(int uid);
    public native void  setProcessFilter(int noSystem);
    
    // CPU
    public native int   getCPUUsage();
    public native long  getCPUDeltaTime();
    public native long  getCPUIdle();
    
    // Memory
    public native long  getMemTotal();
    public native long  getMemFree();
    public native long  getMemBuffers();
    public native long  getMemCached();
    
    // Network
    public native long  getNetTotalRx();
    public native long  getNetTotalTx();
    public native float getNetTotalRxSpeed();
    public native float getNetTotalTxSpeed();
    public native long  getNetRx(int index);
    public native long  getNetTx(int index);
    public native int   getNetRxSpeed(int index);
    public native int   getNetTxSpeed(int index);
    public native String getNetName(int index);
    public native int   getNetNumber();
    
    // File system
    public native long  getSystemTotal();
    public native long  getSystemAvailable();
    public native long  getSystemUsed();
    public native long  getSDCardTotal();
    public native long  getSDCardAvailable();
    public native long  getSDCardUsed();
    public native long  getCacheTotal();
    public native long  getCacheAvailable();
    public native long  getCacheUsed();
    public native long  getDataTotal();
    public native long  getDataAvailable();
    public native long  getDataUsed();
    
    // Power
    public native int GetPowerCapacity();
    public native int GetPowerVoltage();
    public native int GetPowerTemperature();
    public native int GetUSBOnline();
    public native int GetACOnline();
    public native String GetPowerHealth();
    public native String GetPowerStatus();
    public native String GetPowerTechnology();
    
    public void exitApp() {
        exit();
    }
}
